<template>
	<view>
		<view class="signed_title">
			<view class="signed_title_text signed_title_textactive">01.选择银行</view>
			<image class="signed_title_img1" src="../../static/images/signed_02.png"></image>
			<view class="signed_title_text signed_title_textactive">02.添加银行卡</view>
			<image class="signed_title_img1" src="../../static/images/signed_01.png"></image>
			<view class="signed_title_text">02.短信验证</view>
		</view>
		<view class="signed_set_box">
			<view class="signed_set">
				<view class="signed_set_name">银行卡号：</view>
				<input class="signed_set_int" type="number" v-model="backnum" placeholder="请输入卡号" />
			</view>
			<view class="signed_set">
				<view class="signed_set_name">姓名：</view>
				<input class="signed_set_int" type="text" v-model="name" placeholder="请输入姓名" />
			</view>
			<view class="signed_set">
				<view class="signed_set_name">身份证号：</view>
				<input class="signed_set_int" type="idcard" v-model="idcard" placeholder="请输入身份证号" />
			</view>
			<view class="signed_set">
				<view class="signed_set_name">手机号：</view>
				<input class="signed_set_int" type="number" v-model="phonenumber" placeholder="请输入手机号" />
			</view>
			<view class="signed_btn" @click="jump">下一步</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				backnum:'',
				name:'',
				idcard:'',
				phonenumber:'',
				order_sn:'',
				code:''
			}
		},
		onLoad(opt) {
			this.order_sn=opt.order_sn
			this.code=opt.code
		},
		methods: {
			jump(){
				let that = this;
				let reg1 = /^[1-9]\d{9,29}$/;
				let result1 = reg1.test(this.backnum);
				let reg2 = /^(?:[\u4e00-\u9fa5·]{2,16})$/;
				let result2 = reg2.test(this.name);
				let reg3 = /^[1-9]\d{5}(?:18|19|20)\d{2}(?:0[1-9]|10|11|12)(?:0[1-9]|[1-2]\d|30|31)\d{3}[\dXx]$/;
				let result3 = reg3.test(this.idcard)
				let reg4 = /^1[3,4,5,6,7,8,9][0-9]{9}$/;
				let result4 = reg4.test(this.phonenumber);
				if(!result1) {
					uni.showToast({
						title: '银行卡号格式不正确!',
						icon:'none',
						duration: 2000
					});
					return
				}
				if(!result2) {
					uni.showToast({
						title: '姓名格式不正确!',
						icon:'none',
						duration: 2000
					});
					return
				}
				if(!result3) {
					uni.showToast({
						title: '身份证号码格式不正确!',
						icon:'none',
						duration: 2000
					});
					return
				}
				if(!result4) {
					uni.showToast({
						title: '手机号码格式不正确!',
						icon:'none',
						duration: 2000
					});
					return
				}
				
				that.loadStatus = 'loading';
				let dataobj={
					card_type:101,
					card_code:that.backnum,
					cardholder_name:that.name,
					id_number:that.idcard,
					phone:that.phonenumber,
					order_sn:that.order_sn
				}
				that.$http('user.readySign', dataobj, '绑定中...').then(res => {
					if (res.code === 1) {
						console.log(res.data)
						this.$Router.replace({
						  path:`/pages/order/signedthr?id=${res.data.id}&code=${this.code}&phonenumber=${this.phonenumber}`,
						});
					}
				});
				return
				
			}
		}
	}
</script>

<style lang="scss" >
	page{
		background: #fff;
	}
.signed_title{
	height: 92rpx;
	display: flex;
	align-items: center;
	justify-content: center;
	background: #F8F8F8;
	.signed_title_text{
		font-size: 26rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #BBBBBB;
	}
	.signed_title_textactive{
		color: #222222;
	}
	.signed_title_img1{
		width: 46rpx;
		height: 20rpx;
		margin:0 32rpx;
	}
}
.signed_set_box{
	padding-top: 40rpx;
}
.signed_set{
	width: 686rpx;
	height: 108rpx;
	background: rgba(248,248,248,0.88);
	border-radius: 16rpx;
	margin:0 auto;
	margin-bottom: 24rpx;
	display: flex;
	align-items: center;
	padding:0 24rpx;
	box-sizing: border-box;
	.signed_set_name{
		width: 160rpx;
		font-size: 32rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #111111;
	}
	.signed_set_int{
		font-size: 32rpx;
		width:420rpx;
	}
}
.signed_btn{
	width: 686rpx;
	height: 92rpx;
	background: #FBB03B;
	border-radius: 46rpx;
	margin:0 auto;
	margin-top:40rpx;
	text-align: center;
	line-height: 92rpx;
	font-size: 32rpx;
	font-family: SourceHanSansCN-Medium, SourceHanSansCN;
	font-weight: 500;
	color: #111111;
}
</style>
